<?php 
/*
 module:		会员充值订单
 create_time:	2022-04-05 20:59:05
 author:		
 contact:		
*/

namespace app\api\service;
use app\api\model\ZhMatchmakerThankMoney;
use think\facade\Log;
use think\exception\ValidateException;
use xhadmin\CommonService;

class ZhMatchmakerThankMoneyService extends CommonService {


	/*
 	* @Description  列表数据
 	*/
	public static function indexList($where,$field,$orderby,$limit,$page){
		try{

            $res =ZhMatchmakerThankMoney::alias('o')
                ->leftjoin('zh_matchmaker ','o.m_id=zh_matchmaker.matchmaker_id')
                ->leftjoin('zh_authentication ','o.a_id=zh_authentication.authentication_id')
                /*   ->leftjoin('member m','zh_matchmaker.u_id = m.uid')
                   ->leftjoin('member a','zh_authentication.u_id = a.uid')*/
                ->where($where)
                ->field("o.id,o.price,o.status, o.createtime,zh_authentication.real_name a_name,zh_matchmaker.name  m_name ")
                ->order(['createtime' => 'desc'])
                ->paginate(['list_rows'=>$limit,'page'=>$page])
                ->toArray();


		}catch(\Exception $e){
			abort(config('my.error_log_code'),$e->getMessage());
		}
		return ['list'=>$res['data'],'count'=>$res['total']];
	}


	/*
 	* @Description  添加
 	*/
	public static function add($data){
		try{
			$data['status'] = !is_null($data['status']) ? $data['status'] : '0';
			$data['createtime'] = time();
			$res = ZhMatchmakerThankMoney::create($data);
		}catch(ValidateException $e){
			throw new ValidateException ($e->getError());
		}catch(\Exception $e){
			abort(config('my.error_log_code'),$e->getMessage());
		}
		return $res->id;
	}




}

